# -*- codeing = utf-8 -*-
from bs4 import BeautifulSoup
import requests
#请求网址
def get_request(url):
    headers = {
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4506.400'
    }
    resp = requests.get(url=url,headers=headers)
    soup = BeautifulSoup(resp.text,'lxml')
    #print(soup)
    return soup

#请求各大排行榜
def get_yuepiao(html_code):
    yuepiao = html_code.select_one('body > div.wrap > div.rank-box.box-center.cf > div.main-content-wrap.fl > div.rank-body > div > div > h3').text
    #href = html_code.select_one('body > div.wrap > div.rank-box.box-center.cf > div.main-content-wrap.fl > div.rank-body > div > div > h3 >i>a').attrs['href']
    print(yuepiao)
    #小说
    ul_list = html_code.select_one('body > div.wrap > div.rank-box.box-center.cf > div.main-content-wrap.fl > div.rank-body > div > div > i > div > ul')
    print(ul_list)
    # for i in ul_list:
    #     name = i.select_one('div > ul > li.unfold > div > div.book-info.fl > h4 > a')
    #     print(name)
URL = 'https://www.qidian.com/rank/'
#get_request(URL)
get_yuepiao(get_request(URL))